package utils.opt;

import utils.exception.CacheNodeException;
import entities.Individual;
import entities.concept.Concept;
import entities.concept.DomainConceptEQ;
import entities.concept.PConcept;
import entities.role.GeneralRolePath;
import entities.role.Role;

public class TestCache {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Individual ind = Individual.newIndividual("testIND");
		CacheTree ctr = new CacheTree(ind);
		Role r = Role.createRoleAsIs("R");
		Role s = Role.createRoleAsIs("S");
		Role t = Role.createRoleAsIs("T");
		Role f = Role.createRoleAsIs("price");
		Role g = Role.createRoleAsIs("brand");
		// Concept c = new PConcept("C");
		Concept d = PConcept.getPConcept("D");
		Concept d1 = new DomainConceptEQ<Role, String>(f, "100");
		Concept d2 = new DomainConceptEQ<Role, String>(g, "Johnson");
		GeneralRolePath rp1 = new GeneralRolePath();
		rp1.addContent(d1);
		rp1.addContent(s);
		rp1.addContent(d2);
		rp1.addContent(r);
		GeneralRolePath rp2 = new GeneralRolePath();
		rp2.addContent(s);
		rp2.addContent(r);
		rp2.addContent(t);
		GeneralRolePath rp3 = new GeneralRolePath();
		rp3.addContent(s);
		rp3.addContent(d);
		rp3.addContent(s);
		try {
			ctr.insertCacheEntry(ind, rp1, d1);
			// ctr.insertCacheEntry(ind, rp2, c);
			ctr.insertCacheEntry(ind, rp3, d2);
			for (CacheTreeNode nd : ctr.getRoots()) {
				System.out.println(CacheTreeNode.displayTree(nd, 0));
			}
		} catch (CacheNodeException e) {
			e.printStackTrace();
		}

	}

}
